#! /usr/bin/env python3
# encoding: utf-8
"""
@file: __init__.py.py
@author: www.xcooo.cn
@Mail: 602006050@qq.com
"""
from flask import Blueprint

# 初始化蓝图对象
from flask import redirect
from flask import request
from flask import session
from flask import url_for

admin_blu = Blueprint('admin',__name__,url_prefix='/admin')

from . import views

@admin_blu.before_request
def check_admin():
    is_admin = session.get('is_admin',False)
    # if not is_admin and 当前url不是管理员登录页:
    if not is_admin and not request.url.endswith(url_for('admin.login')):
        return redirect('/')